{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "#采用5折交叉验证，用正确率作为评价指标，对线性SVM和RBF核的SVM模型超参数调优。（各50分）\n",
    "#数据处理模块\n",
    "import numpy as np\n",
    "import pandas as pd\n",
    "#数据可视化\n",
    "import matplotlib.pyplot as plt\n",
    "import seaborn as sns\n",
    "\n",
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>pregnants</th>\n",
       "      <th>Plasma_glucose_concentration</th>\n",
       "      <th>blood_pressure</th>\n",
       "      <th>Triceps_skin_fold_thickness</th>\n",
       "      <th>serum_insulin</th>\n",
       "      <th>BMI</th>\n",
       "      <th>Diabetes_pedigree_function</th>\n",
       "      <th>Age</th>\n",
       "      <th>Target</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0.639947</td>\n",
       "      <td>0.866045</td>\n",
       "      <td>-0.031990</td>\n",
       "      <td>0.670643</td>\n",
       "      <td>-0.181541</td>\n",
       "      <td>0.166619</td>\n",
       "      <td>0.468492</td>\n",
       "      <td>1.425995</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>-0.844885</td>\n",
       "      <td>-1.205066</td>\n",
       "      <td>-0.528319</td>\n",
       "      <td>-0.012301</td>\n",
       "      <td>-0.181541</td>\n",
       "      <td>-0.852200</td>\n",
       "      <td>-0.365061</td>\n",
       "      <td>-0.190672</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1.233880</td>\n",
       "      <td>2.016662</td>\n",
       "      <td>-0.693761</td>\n",
       "      <td>-0.012301</td>\n",
       "      <td>-0.181541</td>\n",
       "      <td>-1.332500</td>\n",
       "      <td>0.604397</td>\n",
       "      <td>-0.105584</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>-0.844885</td>\n",
       "      <td>-1.073567</td>\n",
       "      <td>-0.528319</td>\n",
       "      <td>-0.695245</td>\n",
       "      <td>-0.540642</td>\n",
       "      <td>-0.633881</td>\n",
       "      <td>-0.920763</td>\n",
       "      <td>-1.041549</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>-1.141852</td>\n",
       "      <td>0.504422</td>\n",
       "      <td>-2.679076</td>\n",
       "      <td>0.670643</td>\n",
       "      <td>0.316566</td>\n",
       "      <td>1.549303</td>\n",
       "      <td>5.484909</td>\n",
       "      <td>-0.020496</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   pregnants  Plasma_glucose_concentration  blood_pressure  \\\n",
       "0   0.639947                      0.866045       -0.031990   \n",
       "1  -0.844885                     -1.205066       -0.528319   \n",
       "2   1.233880                      2.016662       -0.693761   \n",
       "3  -0.844885                     -1.073567       -0.528319   \n",
       "4  -1.141852                      0.504422       -2.679076   \n",
       "\n",
       "   Triceps_skin_fold_thickness  serum_insulin       BMI  \\\n",
       "0                     0.670643      -0.181541  0.166619   \n",
       "1                    -0.012301      -0.181541 -0.852200   \n",
       "2                    -0.012301      -0.181541 -1.332500   \n",
       "3                    -0.695245      -0.540642 -0.633881   \n",
       "4                     0.670643       0.316566  1.549303   \n",
       "\n",
       "   Diabetes_pedigree_function       Age  Target  \n",
       "0                    0.468492  1.425995       1  \n",
       "1                   -0.365061 -0.190672       0  \n",
       "2                    0.604397 -0.105584       1  \n",
       "3                   -0.920763 -1.041549       0  \n",
       "4                    5.484909 -0.020496       1  "
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#读取数据\n",
    "train=pd.read_csv(\"FE_pima-indians-diabetes1.csv\")\n",
    "train.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(768, 9)"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "train.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "y_train = train['Target']   \n",
    "X_train = train.drop([\"Target\"], axis=1)\n",
    "#保存特征名字以备后用（可视化）\n",
    "feat_names = X_train.columns \n",
    "#导入模型\n",
    "from scipy.sparse import csr_matrix\n",
    "x_train=csr_matrix(X_train)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Fitting 5 folds for each of 14 candidates, totalling 70 fits\n",
      "[CV] C=0.001, penalty=l1 .............................................\n",
      "[CV] C=0.001, penalty=l1 .............................................\n",
      "[CV] C=0.001, penalty=l1 .............................................\n",
      "[CV] C=0.001, penalty=l1 .............................................\n",
      "[CV] .... C=0.001, penalty=l1, score=0.6493506493506493, total=   0.0s\n",
      "[CV] C=0.001, penalty=l1 .............................................\n",
      "[CV] .... C=0.001, penalty=l1, score=0.6493506493506493, total=   0.0s\n",
      "[CV] C=0.001, penalty=l2 .............................................\n",
      "[CV] .... C=0.001, penalty=l1, score=0.6493506493506493, total=   0.0s\n",
      "[CV] .... C=0.001, penalty=l2, score=0.7532467532467533, total=   0.0s\n",
      "[CV] C=0.001, penalty=l2 .............................................\n",
      "[CV] .... C=0.001, penalty=l1, score=0.6535947712418301, total=   0.0s\n",
      "[CV] .... C=0.001, penalty=l1, score=0.6535947712418301, total=   0.1s\n",
      "[CV] C=0.001, penalty=l2 .............................................\n",
      "[CV] C=0.001, penalty=l2 .............................................\n",
      "[CV] .... C=0.001, penalty=l2, score=0.7727272727272727, total=   0.0s\n",
      "[CV] C=0.01, penalty=l2 ..............................................\n",
      "[CV] C=0.01, penalty=l1 ..............................................\n",
      "[CV] .... C=0.001, penalty=l2, score=0.7077922077922078, total=   0.0s\n",
      "[CV] .... C=0.001, penalty=l2, score=0.7973856209150327, total=   0.0s\n",
      "[CV] C=0.001, penalty=l2 .............................................\n",
      "[CV] ..... C=0.01, penalty=l2, score=0.7532467532467533, total=   0.0s\n",
      "[CV] C=0.01, penalty=l2 ..............................................\n",
      "[CV] C=0.1, penalty=l1 ...............................................\n",
      "[CV] ..... C=0.01, penalty=l1, score=0.7727272727272727, total=   0.0s\n",
      "[CV] ...... C=0.1, penalty=l1, score=0.7597402597402597, total=   0.0s\n",
      "[CV] .... C=0.001, penalty=l2, score=0.7712418300653595, total=   0.0s\n",
      "[CV] ..... C=0.01, penalty=l2, score=0.7792207792207793, total=   0.0s\n",
      "[CV] C=0.01, penalty=l1 ..............................................\n",
      "[CV] C=0.1, penalty=l1 ...............................................\n",
      "[CV] C=0.01, penalty=l2 ..............................................\n",
      "[CV] C=0.01, penalty=l1 ..............................................\n",
      "[CV] ..... C=0.01, penalty=l1, score=0.7908496732026143, total=   0.0s\n",
      "[CV] ...... C=0.1, penalty=l1, score=0.7467532467532467, total=   0.0s\n",
      "[CV] ..... C=0.01, penalty=l1, score=0.7532467532467533, total=   0.0s\n",
      "[CV] C=0.1, penalty=l1 ...............................................\n",
      "[CV] C=0.01, penalty=l1 ..............................................\n",
      "[CV] ..... C=0.01, penalty=l1, score=0.7712418300653595, total=   0.0s\n",
      "[CV] C=0.01, penalty=l1 ..............................................\n",
      "[CV] C=0.01, penalty=l2 ..............................................\n",
      "[CV] ...... C=0.1, penalty=l1, score=0.7792207792207793, total=   0.0s\n",
      "[CV] ..... C=0.01, penalty=l2, score=0.7973856209150327, total=   0.0s\n",
      "[CV] ..... C=0.01, penalty=l1, score=0.7272727272727273, total=   0.0s\n",
      "[CV] ..... C=0.01, penalty=l2, score=0.7597402597402597, total=   0.0s\n",
      "[CV] C=0.1, penalty=l1 ...............................................\n",
      "[CV] C=0.01, penalty=l2 ..............................................\n",
      "[CV] C=0.1, penalty=l1 ...............................................\n",
      "[CV] ..... C=0.01, penalty=l2, score=0.7712418300653595, total=   0.0s\n",
      "[CV] C=0.1, penalty=l2 ...............................................\n",
      "[CV] ...... C=0.1, penalty=l1, score=0.7647058823529411, total=   0.0s\n",
      "[CV] C=0.1, penalty=l2 ...............................................\n",
      "[CV] ...... C=0.1, penalty=l1, score=0.7908496732026143, total=   0.0s\n",
      "[CV] C=1, penalty=l1 .................................................\n",
      "[CV] C=1, penalty=l2 .................................................\n",
      "[CV] ........ C=1, penalty=l1, score=0.7792207792207793, total=   0.0s\n",
      "[CV] ...... C=0.1, penalty=l2, score=0.7908496732026143, total=   0.0s\n",
      "[CV] ...... C=0.1, penalty=l2, score=0.7597402597402597, total=   0.0s\n",
      "[CV] C=1, penalty=l1 .................................................\n",
      "[CV] C=0.1, penalty=l2 ...............................................\n",
      "[CV] ........ C=1, penalty=l2, score=0.7532467532467533, total=   0.0s\n",
      "[CV] C=0.1, penalty=l2 ...............................................\n",
      "[CV] C=1, penalty=l2 .................................................\n",
      "[CV] ...... C=0.1, penalty=l2, score=0.7532467532467533, total=   0.0s\n",
      "[CV] ........ C=1, penalty=l1, score=0.7973856209150327, total=   0.0s\n",
      "[CV] ...... C=0.1, penalty=l2, score=0.7712418300653595, total=   0.0s\n",
      "[CV] C=1, penalty=l1 .................................................\n",
      "[CV] ........ C=1, penalty=l2, score=0.7792207792207793, total=   0.0s\n",
      "[CV] C=1, penalty=l1 .................................................\n",
      "[CV] C=0.1, penalty=l2 ...............................................\n",
      "[CV] C=1, penalty=l2 .................................................\n",
      "[CV] ........ C=1, penalty=l1, score=0.7712418300653595, total=   0.0s\n",
      "[CV] ...... C=0.1, penalty=l2, score=0.7792207792207793, total=   0.0s\n",
      "[CV] C=1, penalty=l2 .................................................\n",
      "[CV] ........ C=1, penalty=l2, score=0.7597402597402597, total=   0.0s\n",
      "[CV] ........ C=1, penalty=l2, score=0.7973856209150327, total=   0.0s\n",
      "[CV] ........ C=1, penalty=l1, score=0.7597402597402597, total=   0.0s\n",
      "[CV] C=10, penalty=l1 ................................................\n",
      "[CV] C=1, penalty=l2 .................................................\n",
      "[CV] C=1, penalty=l1 .................................................\n",
      "[CV] C=10, penalty=l1 ................................................\n",
      "[CV] ....... C=10, penalty=l1, score=0.7712418300653595, total=   0.0s\n",
      "[CV] ........ C=1, penalty=l2, score=0.7712418300653595, total=   0.0s\n",
      "[CV] ........ C=1, penalty=l1, score=0.7532467532467533, total=   0.0s\n",
      "[CV] ....... C=10, penalty=l1, score=0.7597402597402597, total=   0.0s\n",
      "[CV] C=10, penalty=l2 ................................................\n",
      "[CV] C=100, penalty=l1 ...............................................\n",
      "[CV] C=10, penalty=l1 ................................................\n",
      "[CV] C=10, penalty=l2 ................................................\n",
      "[CV] ....... C=10, penalty=l2, score=0.7973856209150327, total=   0.0s\n",
      "[CV] C=10, penalty=l2 ................................................\n",
      "[CV] ...... C=100, penalty=l1, score=0.7792207792207793, total=   0.0s\n",
      "[CV] ....... C=10, penalty=l2, score=0.7597402597402597, total=   0.0s\n",
      "[CV] ....... C=10, penalty=l1, score=0.7532467532467533, total=   0.0s\n",
      "[CV] C=10, penalty=l1 ................................................\n",
      "[CV] C=100, penalty=l1 ...............................................\n",
      "[CV] ....... C=10, penalty=l2, score=0.7712418300653595, total=   0.0s\n",
      "[CV] ....... C=10, penalty=l1, score=0.7792207792207793, total=   0.0s\n",
      "[CV] C=100, penalty=l1 ...............................................\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "[Parallel(n_jobs=-1)]: Done  16 tasks      | elapsed:    0.3s\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[CV] C=10, penalty=l2 ................................................\n",
      "[CV] ...... C=100, penalty=l1, score=0.7973856209150327, total=   0.0s\n",
      "[CV] C=10, penalty=l1 ................................................\n",
      "[CV] ....... C=10, penalty=l2, score=0.7532467532467533, total=   0.0s\n",
      "[CV] C=100, penalty=l1 ...............................................\n",
      "[CV] ...... C=100, penalty=l1, score=0.7597402597402597, total=   0.0s\n",
      "[CV] ....... C=10, penalty=l1, score=0.7973856209150327, total=   0.0s\n",
      "[CV] ...... C=100, penalty=l1, score=0.7712418300653595, total=   0.0s\n",
      "[CV] C=10, penalty=l2 ................................................\n",
      "[CV] C=100, penalty=l2 ...............................................\n",
      "[CV] C=100, penalty=l1 ...............................................\n",
      "[CV] C=100, penalty=l2 ...............................................\n",
      "[CV] ....... C=10, penalty=l2, score=0.7792207792207793, total=   0.0s\n",
      "[CV] ...... C=100, penalty=l2, score=0.7532467532467533, total=   0.0s\n",
      "[CV] C=1000, penalty=l1 ..............................................\n",
      "[CV] ...... C=100, penalty=l2, score=0.7597402597402597, total=   0.0s\n",
      "[CV] ...... C=100, penalty=l1, score=0.7532467532467533, total=   0.0s\n",
      "[CV] ..... C=1000, penalty=l1, score=0.7597402597402597, total=   0.0s\n",
      "[CV] C=1000, penalty=l1 ..............................................\n",
      "[CV] C=100, penalty=l2 ...............................................\n",
      "[CV] C=1000, penalty=l2 ..............................................\n",
      "[CV] C=1000, penalty=l1 ..............................................\n",
      "[CV] ..... C=1000, penalty=l1, score=0.7712418300653595, total=   0.0s\n",
      "[CV] C=1000, penalty=l2 ..............................................\n",
      "[CV] ...... C=100, penalty=l2, score=0.7792207792207793, total=   0.0s\n",
      "[CV] C=100, penalty=l2 ...............................................\n",
      "[CV] ..... C=1000, penalty=l2, score=0.7973856209150327, total=   0.0s\n",
      "[CV] C=1000, penalty=l2 ..............................................\n",
      "[CV] ..... C=1000, penalty=l2, score=0.7712418300653595, total=   0.0s\n",
      "[CV] ..... C=1000, penalty=l1, score=0.7532467532467533, total=   0.0s\n",
      "[CV] ...... C=100, penalty=l2, score=0.7973856209150327, total=   0.0s\n",
      "[CV] ..... C=1000, penalty=l2, score=0.7597402597402597, total=   0.0s\n",
      "[CV] C=1000, penalty=l2 ..............................................\n",
      "[CV] C=100, penalty=l2 ...............................................\n",
      "[CV] C=1000, penalty=l1 ..............................................\n",
      "[CV] ..... C=1000, penalty=l2, score=0.7532467532467533, total=   0.0s\n",
      "[CV] ...... C=100, penalty=l2, score=0.7712418300653595, total=   0.0s\n",
      "[CV] C=1000, penalty=l2 ..............................................\n",
      "[CV] ..... C=1000, penalty=l1, score=0.7792207792207793, total=   0.0s\n",
      "[CV] C=1000, penalty=l1 ..............................................\n",
      "[CV] ..... C=1000, penalty=l2, score=0.7792207792207793, total=   0.0s\n",
      "[CV] ..... C=1000, penalty=l1, score=0.7973856209150327, total=   0.0s\n",
      "0.7721354166666666\n",
      "{'C': 0.01, 'penalty': 'l2'}\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "[Parallel(n_jobs=-1)]: Done  48 out of  70 | elapsed:    0.6s remaining:    0.3s\n",
      "[Parallel(n_jobs=-1)]: Done  70 out of  70 | elapsed:    0.7s finished\n"
     ]
    }
   ],
   "source": [
    "#线性超参数调优\n",
    "from sklearn.model_selection import StratifiedKFold\n",
    "fold=StratifiedKFold(n_splits=5,shuffle=True,random_state=777)\n",
    "from sklearn.model_selection import GridSearchCV\n",
    "from sklearn.svm import LinearSVC\n",
    "#设置参数搜索范围\n",
    "penaltys=['l1','l2']\n",
    "Cs=[0.001,0.01,0.1,1,10,100,1000]\n",
    "\n",
    "#调优的参数集合，在网格上的交叉点进行搜索\n",
    "tuned_parameters=dict(penalty=penaltys,C=Cs)\n",
    "SVC1=LinearSVC(dual=False)\n",
    "grid=GridSearchCV(SVC1,tuned_parameters,cv=5,scoring='accuracy',n_jobs=-1,verbose=5)\n",
    "grid.fit(X_train,y_train)\n",
    "print(grid.best_score_)\n",
    "print(grid.best_params_)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Fitting 5 folds for each of 42 candidates, totalling 210 fits\n",
      "[CV] C=0.001, gamma=0.0001 ...........................................\n",
      "[CV] C=0.001, gamma=0.0001 ...........................................\n",
      "[CV] C=0.001, gamma=0.0001 ...........................................\n",
      "[CV] C=0.001, gamma=0.0001 ...........................................\n",
      "[CV] .. C=0.001, gamma=0.0001, score=0.6493506493506493, total=   0.0s\n",
      "[CV] C=0.001, gamma=0.0001 ...........................................\n",
      "[CV] .. C=0.001, gamma=0.0001, score=0.6493506493506493, total=   0.1s\n",
      "[CV] C=0.001, gamma=0.001 ............................................\n",
      "[CV] .. C=0.001, gamma=0.0001, score=0.6493506493506493, total=   0.1s\n",
      "[CV] C=0.001, gamma=0.001 ............................................\n",
      "[CV] ... C=0.001, gamma=0.001, score=0.6493506493506493, total=   0.0s\n",
      "[CV] .. C=0.001, gamma=0.0001, score=0.6535947712418301, total=   0.1s\n",
      "[CV] C=0.001, gamma=0.001 ............................................\n",
      "[CV] C=0.001, gamma=0.001 ............................................\n",
      "[CV] .. C=0.001, gamma=0.0001, score=0.6535947712418301, total=   0.1s\n",
      "[CV] C=0.001, gamma=0.01 .............................................\n",
      "[CV] ... C=0.001, gamma=0.001, score=0.6493506493506493, total=   0.1s\n",
      "[CV] C=0.001, gamma=0.01 .............................................\n",
      "[CV] ... C=0.001, gamma=0.001, score=0.6535947712418301, total=   0.0s\n",
      "[CV] C=0.001, gamma=0.001 ............................................\n",
      "[CV] ... C=0.001, gamma=0.001, score=0.6493506493506493, total=   0.1s\n",
      "[CV] C=0.001, gamma=0.01 .............................................\n",
      "[CV] .... C=0.001, gamma=0.01, score=0.6493506493506493, total=   0.1s\n",
      "[CV] C=0.001, gamma=0.01 .............................................\n",
      "[CV] .... C=0.001, gamma=0.01, score=0.6493506493506493, total=   0.1s\n",
      "[CV] .... C=0.001, gamma=0.01, score=0.6535947712418301, total=   0.0s\n",
      "[CV] C=0.001, gamma=0.1 ..............................................\n",
      "[CV] ... C=0.001, gamma=0.001, score=0.6535947712418301, total=   0.1s\n",
      "[CV] .... C=0.001, gamma=0.01, score=0.6493506493506493, total=   0.0s\n",
      "[CV] C=0.001, gamma=0.1 ..............................................\n",
      "[CV] C=0.001, gamma=0.1 ..............................................\n",
      "[CV] C=0.001, gamma=0.01 .............................................\n",
      "[CV] ..... C=0.001, gamma=0.1, score=0.6493506493506493, total=   0.0s\n",
      "[CV] ..... C=0.001, gamma=0.1, score=0.6493506493506493, total=   0.0s\n",
      "[CV] C=0.001, gamma=1 ................................................\n",
      "[CV] ..... C=0.001, gamma=0.1, score=0.6535947712418301, total=   0.0s\n",
      "[CV] C=0.001, gamma=0.1 ..............................................\n",
      "[CV] C=0.001, gamma=0.1 ..............................................\n",
      "[CV] .... C=0.001, gamma=0.01, score=0.6535947712418301, total=   0.1s\n",
      "[CV] C=0.001, gamma=1 ................................................\n",
      "[CV] ....... C=0.001, gamma=1, score=0.6493506493506493, total=   0.0s\n",
      "[CV] ..... C=0.001, gamma=0.1, score=0.6535947712418301, total=   0.0s\n",
      "[CV] C=0.001, gamma=1 ................................................\n",
      "[CV] ..... C=0.001, gamma=0.1, score=0.6493506493506493, total=   0.0s\n",
      "[CV] C=0.001, gamma=1 ................................................\n",
      "[CV] C=0.001, gamma=1.0 ..............................................\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "[Parallel(n_jobs=-1)]: Done  12 tasks      | elapsed:    0.4s\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[CV] ....... C=0.001, gamma=1, score=0.6493506493506493, total=   0.1s\n",
      "[CV] C=0.001, gamma=1 ................................................\n",
      "[CV] ....... C=0.001, gamma=1, score=0.6493506493506493, total=   0.0s\n",
      "[CV] ..... C=0.001, gamma=1.0, score=0.6493506493506493, total=   0.0s\n",
      "[CV] ....... C=0.001, gamma=1, score=0.6535947712418301, total=   0.0s\n",
      "[CV] C=0.001, gamma=1.0 ..............................................\n",
      "[CV] C=0.001, gamma=1.0 ..............................................\n",
      "[CV] C=0.001, gamma=1.0 ..............................................\n",
      "[CV] ....... C=0.001, gamma=1, score=0.6535947712418301, total=   0.0s\n",
      "[CV] ..... C=0.001, gamma=1.0, score=0.6535947712418301, total=   0.1s\n",
      "[CV] C=0.001, gamma=1.0 ..............................................\n",
      "[CV] C=0.01, gamma=0.0001 ............................................\n",
      "[CV] ..... C=0.001, gamma=1.0, score=0.6493506493506493, total=   0.0s\n",
      "[CV] C=0.01, gamma=0.0001 ............................................\n",
      "[CV] ..... C=0.001, gamma=1.0, score=0.6493506493506493, total=   0.1s\n",
      "[CV] C=0.01, gamma=0.0001 ............................................\n",
      "[CV] ... C=0.01, gamma=0.0001, score=0.6493506493506493, total=   0.0s\n",
      "[CV] ..... C=0.001, gamma=1.0, score=0.6535947712418301, total=   0.1s\n",
      "[CV] C=0.01, gamma=0.0001 ............................................\n",
      "[CV] ... C=0.01, gamma=0.0001, score=0.6493506493506493, total=   0.1s\n",
      "[CV] C=0.01, gamma=0.0001 ............................................\n",
      "[CV] C=0.01, gamma=0.001 .............................................\n",
      "[CV] ... C=0.01, gamma=0.0001, score=0.6535947712418301, total=   0.1s\n",
      "[CV] C=0.01, gamma=0.001 .............................................\n",
      "[CV] ... C=0.01, gamma=0.0001, score=0.6535947712418301, total=   0.1s\n",
      "[CV] C=0.01, gamma=0.001 .............................................\n",
      "[CV] .... C=0.01, gamma=0.001, score=0.6493506493506493, total=   0.1s\n",
      "[CV] ... C=0.01, gamma=0.0001, score=0.6493506493506493, total=   0.1s\n",
      "[CV] C=0.01, gamma=0.001 .............................................\n",
      "[CV] C=0.01, gamma=0.01 ..............................................\n",
      "[CV] .... C=0.01, gamma=0.001, score=0.6535947712418301, total=   0.0s\n",
      "[CV] C=0.01, gamma=0.001 .............................................\n",
      "[CV] .... C=0.01, gamma=0.001, score=0.6535947712418301, total=   0.0s\n",
      "[CV] C=0.01, gamma=0.01 ..............................................\n",
      "[CV] .... C=0.01, gamma=0.001, score=0.6493506493506493, total=   0.1s\n",
      "[CV] .... C=0.01, gamma=0.001, score=0.6493506493506493, total=   0.0s\n",
      "[CV] C=0.01, gamma=0.01 ..............................................\n",
      "[CV] C=0.01, gamma=0.1 ...............................................\n",
      "[CV] ..... C=0.01, gamma=0.01, score=0.6493506493506493, total=   0.1s\n",
      "[CV] C=0.01, gamma=0.01 ..............................................\n",
      "[CV] ..... C=0.01, gamma=0.01, score=0.6493506493506493, total=   0.0s\n",
      "[CV] C=0.01, gamma=0.01 ..............................................\n",
      "[CV] ..... C=0.01, gamma=0.01, score=0.6535947712418301, total=   0.0s\n",
      "[CV] ...... C=0.01, gamma=0.1, score=0.6493506493506493, total=   0.0s\n",
      "[CV] C=0.01, gamma=0.1 ...............................................\n",
      "[CV] C=0.01, gamma=0.1 ...............................................\n",
      "[CV] ..... C=0.01, gamma=0.01, score=0.6493506493506493, total=   0.1s\n",
      "[CV] C=0.01, gamma=0.1 ...............................................\n",
      "[CV] ...... C=0.01, gamma=0.1, score=0.6493506493506493, total=   0.0s\n",
      "[CV] ...... C=0.01, gamma=0.1, score=0.6493506493506493, total=   0.0s\n",
      "[CV] C=0.01, gamma=1 .................................................\n",
      "[CV] ..... C=0.01, gamma=0.01, score=0.6535947712418301, total=   0.1s\n",
      "[CV] C=0.01, gamma=1 .................................................\n",
      "[CV] C=0.01, gamma=1 .................................................\n",
      "[CV] ...... C=0.01, gamma=0.1, score=0.6535947712418301, total=   0.1s\n",
      "[CV] C=0.01, gamma=0.1 ...............................................\n",
      "[CV] ........ C=0.01, gamma=1, score=0.6493506493506493, total=   0.1s\n",
      "[CV] ........ C=0.01, gamma=1, score=0.6493506493506493, total=   0.1s\n",
      "[CV] C=0.01, gamma=1 .................................................\n",
      "[CV] C=0.01, gamma=1 .................................................\n",
      "[CV] ........ C=0.01, gamma=1, score=0.6535947712418301, total=   0.1s\n",
      "[CV] ...... C=0.01, gamma=0.1, score=0.6535947712418301, total=   0.0s\n",
      "[CV] C=0.01, gamma=1.0 ...............................................\n",
      "[CV] C=0.01, gamma=1.0 ...............................................\n",
      "[CV] ........ C=0.01, gamma=1, score=0.6535947712418301, total=   0.0s\n",
      "[CV] C=0.01, gamma=1.0 ...............................................\n",
      "[CV] ........ C=0.01, gamma=1, score=0.6493506493506493, total=   0.0s\n",
      "[CV] C=0.1, gamma=0.0001 .............................................\n",
      "[CV] ...... C=0.01, gamma=1.0, score=0.6493506493506493, total=   0.0s\n",
      "[CV] C=0.1, gamma=0.0001 .............................................\n",
      "[CV] ...... C=0.01, gamma=1.0, score=0.6535947712418301, total=   0.0s\n",
      "[CV] ...... C=0.01, gamma=1.0, score=0.6493506493506493, total=   0.0s\n",
      "[CV] C=0.01, gamma=1.0 ...............................................\n",
      "[CV] .... C=0.1, gamma=0.0001, score=0.6493506493506493, total=   0.0s\n",
      "[CV] C=0.01, gamma=1.0 ...............................................\n",
      "[CV] C=0.1, gamma=0.0001 .............................................\n",
      "[CV] ...... C=0.01, gamma=1.0, score=0.6535947712418301, total=   0.0s\n",
      "[CV] C=0.1, gamma=0.0001 .............................................\n",
      "[CV] .... C=0.1, gamma=0.0001, score=0.6493506493506493, total=   0.0s\n",
      "[CV] C=0.1, gamma=0.0001 .............................................\n",
      "[CV] .... C=0.1, gamma=0.0001, score=0.6493506493506493, total=   0.0s\n",
      "[CV] ...... C=0.01, gamma=1.0, score=0.6493506493506493, total=   0.0s\n",
      "[CV] C=0.1, gamma=0.001 ..............................................\n",
      "[CV] C=0.1, gamma=0.001 ..............................................\n",
      "[CV] .... C=0.1, gamma=0.0001, score=0.6535947712418301, total=   0.0s\n",
      "[CV] C=0.1, gamma=0.001 ..............................................\n",
      "[CV] ..... C=0.1, gamma=0.001, score=0.6493506493506493, total=   0.0s\n",
      "[CV] C=0.1, gamma=0.001 ..............................................\n",
      "[CV] .... C=0.1, gamma=0.0001, score=0.6535947712418301, total=   0.0s\n",
      "[CV] C=0.1, gamma=0.01 ...............................................\n",
      "[CV] ..... C=0.1, gamma=0.001, score=0.6535947712418301, total=   0.1s\n",
      "[CV] ..... C=0.1, gamma=0.001, score=0.6493506493506493, total=   0.0s\n",
      "[CV] C=0.1, gamma=0.01 ...............................................\n",
      "[CV] C=0.1, gamma=0.001 ..............................................\n",
      "[CV] ..... C=0.1, gamma=0.001, score=0.6493506493506493, total=   0.0s\n",
      "[CV] C=0.1, gamma=0.01 ...............................................\n",
      "[CV] ...... C=0.1, gamma=0.01, score=0.6558441558441559, total=   0.0s\n",
      "[CV] ...... C=0.1, gamma=0.01, score=0.6558441558441559, total=   0.0s\n",
      "[CV] C=0.1, gamma=0.01 ...............................................\n",
      "[CV] C=0.1, gamma=0.01 ...............................................\n",
      "[CV] ..... C=0.1, gamma=0.001, score=0.6535947712418301, total=   0.0s\n",
      "[CV] C=0.1, gamma=0.1 ................................................\n",
      "[CV] ....... C=0.1, gamma=0.1, score=0.7597402597402597, total=   0.0s\n",
      "[CV] ...... C=0.1, gamma=0.01, score=0.6535947712418301, total=   0.0s\n",
      "[CV] ...... C=0.1, gamma=0.01, score=0.6493506493506493, total=   0.0s\n",
      "[CV] C=0.1, gamma=0.1 ................................................\n",
      "[CV] C=0.1, gamma=0.1 ................................................\n",
      "[CV] C=0.1, gamma=1 ..................................................\n",
      "[CV] ...... C=0.1, gamma=0.01, score=0.6470588235294118, total=   0.1s\n",
      "[CV] C=0.1, gamma=0.1 ................................................\n",
      "[CV] ....... C=0.1, gamma=0.1, score=0.7727272727272727, total=   0.0s\n",
      "[CV] C=0.1, gamma=1 ..................................................\n",
      "[CV] ......... C=0.1, gamma=1, score=0.6493506493506493, total=   0.0s\n",
      "[CV] ....... C=0.1, gamma=0.1, score=0.7337662337662337, total=   0.0s\n",
      "[CV] C=0.1, gamma=1 ..................................................\n",
      "[CV] C=0.1, gamma=1 ..................................................\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[CV] ....... C=0.1, gamma=0.1, score=0.7712418300653595, total=   0.0s\n",
      "[CV] C=0.1, gamma=0.1 ................................................\n",
      "[CV] ....... C=0.1, gamma=0.1, score=0.7712418300653595, total=   0.0s\n",
      "[CV] ......... C=0.1, gamma=1, score=0.6493506493506493, total=   0.0s\n",
      "[CV] C=0.1, gamma=1.0 ................................................\n",
      "[CV] C=0.1, gamma=1.0 ................................................\n",
      "[CV] ......... C=0.1, gamma=1, score=0.6535947712418301, total=   0.1s\n",
      "[CV] C=0.1, gamma=1.0 ................................................\n",
      "[CV] ......... C=0.1, gamma=1, score=0.6493506493506493, total=   0.1s\n",
      "[CV] C=0.1, gamma=1 ..................................................\n",
      "[CV] ....... C=0.1, gamma=1.0, score=0.6493506493506493, total=   0.0s\n",
      "[CV] C=1, gamma=0.0001 ...............................................\n",
      "[CV] ....... C=0.1, gamma=1.0, score=0.6493506493506493, total=   0.1s\n",
      "[CV] C=0.1, gamma=1.0 ................................................\n",
      "[CV] ......... C=0.1, gamma=1, score=0.6535947712418301, total=   0.0s\n",
      "[CV] ...... C=1, gamma=0.0001, score=0.6493506493506493, total=   0.0s\n",
      "[CV] C=1, gamma=0.0001 ...............................................\n",
      "[CV] ....... C=0.1, gamma=1.0, score=0.6535947712418301, total=   0.1s\n",
      "[CV] C=1, gamma=0.0001 ...............................................\n",
      "[CV] C=0.1, gamma=1.0 ................................................\n",
      "[CV] ...... C=1, gamma=0.0001, score=0.6493506493506493, total=   0.0s\n",
      "[CV] C=1, gamma=0.0001 ...............................................\n",
      "[CV] ....... C=0.1, gamma=1.0, score=0.6493506493506493, total=   0.0s\n",
      "[CV] C=1, gamma=0.001 ................................................\n",
      "[CV] ...... C=1, gamma=0.0001, score=0.6493506493506493, total=   0.0s\n",
      "[CV] C=1, gamma=0.0001 ...............................................\n",
      "[CV] ...... C=1, gamma=0.0001, score=0.6535947712418301, total=   0.0s\n",
      "[CV] ....... C=0.1, gamma=1.0, score=0.6535947712418301, total=   0.1s\n",
      "[CV] C=1, gamma=0.001 ................................................\n",
      "[CV] ....... C=1, gamma=0.001, score=0.6948051948051948, total=   0.0s\n",
      "[CV] C=1, gamma=0.001 ................................................\n",
      "[CV] C=1, gamma=0.001 ................................................\n",
      "[CV] ...... C=1, gamma=0.0001, score=0.6535947712418301, total=   0.0s\n",
      "[CV] C=1, gamma=0.01 .................................................\n",
      "[CV] ....... C=1, gamma=0.001, score=0.6948051948051948, total=   0.0s\n",
      "[CV] C=1, gamma=0.01 .................................................\n",
      "[CV] ........ C=1, gamma=0.001, score=0.673202614379085, total=   0.0s\n",
      "[CV] C=1, gamma=0.001 ................................................\n",
      "[CV] ....... C=1, gamma=0.001, score=0.6818181818181818, total=   0.0s\n",
      "[CV] C=1, gamma=0.01 .................................................\n",
      "[CV] ........ C=1, gamma=0.01, score=0.7597402597402597, total=   0.0s\n",
      "[CV] C=1, gamma=0.01 .................................................\n",
      "[CV] ........ C=1, gamma=0.01, score=0.7857142857142857, total=   0.0s\n",
      "[CV] C=1, gamma=0.01 .................................................\n",
      "[CV] ........ C=1, gamma=0.01, score=0.7647058823529411, total=   0.0s\n",
      "[CV] C=1, gamma=0.1 ..................................................\n",
      "[CV] ........ C=1, gamma=0.01, score=0.7337662337662337, total=   0.0s\n",
      "[CV] ........ C=1, gamma=0.01, score=0.7908496732026143, total=   0.0s\n",
      "[CV] ....... C=1, gamma=0.001, score=0.6797385620915033, total=   0.0s\n",
      "[CV] C=1, gamma=0.1 ..................................................\n",
      "[CV] C=1, gamma=0.1 ..................................................\n",
      "[CV] C=1, gamma=1 ....................................................\n",
      "[CV] ......... C=1, gamma=0.1, score=0.7467532467532467, total=   0.0s\n",
      "[CV] ......... C=1, gamma=0.1, score=0.7272727272727273, total=   0.0s\n",
      "[CV] C=1, gamma=1 ....................................................\n",
      "[CV] C=1, gamma=0.1 ..................................................\n",
      "[CV] ......... C=1, gamma=0.1, score=0.7973856209150327, total=   0.1s\n",
      "[CV] C=1, gamma=0.1 ..................................................\n",
      "[CV] ......... C=1, gamma=0.1, score=0.7532467532467533, total=   0.0s\n",
      "[CV] ........... C=1, gamma=1, score=0.7077922077922078, total=   0.0s\n",
      "[CV] C=1, gamma=1 ....................................................\n",
      "[CV] ........... C=1, gamma=1, score=0.6883116883116883, total=   0.1s\n",
      "[CV] C=1, gamma=1 ....................................................\n",
      "[CV] C=1, gamma=1 ....................................................\n",
      "[CV] ......... C=1, gamma=0.1, score=0.7581699346405228, total=   0.0s\n",
      "[CV] ........... C=1, gamma=1, score=0.7581699346405228, total=   0.0s\n",
      "[CV] C=1, gamma=1.0 ..................................................\n",
      "[CV] C=1, gamma=1.0 ..................................................\n",
      "[CV] ........... C=1, gamma=1, score=0.6558441558441559, total=   0.1s\n",
      "[CV] C=10, gamma=0.0001 ..............................................\n",
      "[CV] ........... C=1, gamma=1, score=0.7189542483660131, total=   0.1s\n",
      "[CV] C=1, gamma=1.0 ..................................................\n",
      "[CV] ......... C=1, gamma=1.0, score=0.6558441558441559, total=   0.1s\n",
      "[CV] C=1, gamma=1.0 ..................................................\n",
      "[CV] ......... C=1, gamma=1.0, score=0.7581699346405228, total=   0.1s\n",
      "[CV] ..... C=10, gamma=0.0001, score=0.6948051948051948, total=   0.0s\n",
      "[CV] C=1, gamma=1.0 ..................................................\n",
      "[CV] C=10, gamma=0.0001 ..............................................\n",
      "[CV] ......... C=1, gamma=1.0, score=0.6883116883116883, total=   0.1s\n",
      "[CV] C=10, gamma=0.0001 ..............................................\n",
      "[CV] ......... C=1, gamma=1.0, score=0.7077922077922078, total=   0.0s\n",
      "[CV] C=10, gamma=0.0001 ..............................................\n",
      "[CV] ......... C=1, gamma=1.0, score=0.7189542483660131, total=   0.1s\n",
      "[CV] C=10, gamma=0.001 ...............................................\n",
      "[CV] ..... C=10, gamma=0.0001, score=0.6948051948051948, total=   0.1s\n",
      "[CV] C=10, gamma=0.001 ...............................................\n",
      "[CV] ..... C=10, gamma=0.0001, score=0.6797385620915033, total=   0.0s\n",
      "[CV] ..... C=10, gamma=0.0001, score=0.6818181818181818, total=   0.1s\n",
      "[CV] C=10, gamma=0.001 ...............................................\n",
      "[CV] C=10, gamma=0.0001 ..............................................\n",
      "[CV] ...... C=10, gamma=0.001, score=0.7467532467532467, total=   0.0s\n",
      "[CV] C=10, gamma=0.001 ...............................................\n",
      "[CV] ...... C=10, gamma=0.001, score=0.7908496732026143, total=   0.0s\n",
      "[CV] C=10, gamma=0.001 ...............................................\n",
      "[CV] ...... C=10, gamma=0.0001, score=0.673202614379085, total=   0.1s\n",
      "[CV] ...... C=10, gamma=0.001, score=0.7727272727272727, total=   0.0s\n",
      "[CV] ...... C=10, gamma=0.001, score=0.7516339869281046, total=   0.0s\n",
      "[CV] C=10, gamma=0.01 ................................................\n",
      "[CV] ...... C=10, gamma=0.001, score=0.7597402597402597, total=   0.0s\n",
      "[CV] C=10, gamma=0.01 ................................................\n",
      "[CV] C=10, gamma=0.01 ................................................\n",
      "[CV] C=10, gamma=0.1 .................................................\n",
      "[CV] ....... C=10, gamma=0.01, score=0.7727272727272727, total=   0.0s\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "[Parallel(n_jobs=-1)]: Done 120 tasks      | elapsed:    2.8s\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[CV] ....... C=10, gamma=0.01, score=0.7662337662337663, total=   0.0s\n",
      "[CV] C=10, gamma=0.01 ................................................\n",
      "[CV] ........ C=10, gamma=0.1, score=0.7142857142857143, total=   0.0s\n",
      "[CV] C=10, gamma=0.01 ................................................\n",
      "[CV] C=10, gamma=0.1 .................................................\n",
      "[CV] ....... C=10, gamma=0.01, score=0.7516339869281046, total=   0.0s\n",
      "[CV] ....... C=10, gamma=0.01, score=0.7647058823529411, total=   0.0s\n",
      "[CV] C=10, gamma=0.1 .................................................\n",
      "[CV] C=10, gamma=0.1 .................................................\n",
      "[CV] ....... C=10, gamma=0.01, score=0.7532467532467533, total=   0.0s\n",
      "[CV] ........ C=10, gamma=0.1, score=0.7337662337662337, total=   0.0s\n",
      "[CV] C=10, gamma=1 ...................................................\n",
      "[CV] ........ C=10, gamma=0.1, score=0.7012987012987013, total=   0.0s\n",
      "[CV] C=10, gamma=1 ...................................................\n",
      "[CV] C=10, gamma=1 ...................................................\n",
      "[CV] ........ C=10, gamma=0.1, score=0.7908496732026143, total=   0.1s\n",
      "[CV] .......... C=10, gamma=1, score=0.6818181818181818, total=   0.1s\n",
      "[CV] C=10, gamma=0.1 .................................................\n",
      "[CV] .......... C=10, gamma=1, score=0.6753246753246753, total=   0.1s\n",
      "[CV] C=10, gamma=1 ...................................................\n",
      "[CV] C=10, gamma=1 ...................................................\n",
      "[CV] ........... C=10, gamma=1, score=0.673202614379085, total=   0.1s\n",
      "[CV] ........ C=10, gamma=0.1, score=0.7712418300653595, total=   0.0s\n",
      "[CV] C=10, gamma=1.0 .................................................\n",
      "[CV] C=10, gamma=1.0 .................................................\n",
      "[CV] .......... C=10, gamma=1, score=0.7581699346405228, total=   0.1s\n",
      "[CV] C=10, gamma=1.0 .................................................\n",
      "[CV] .......... C=10, gamma=1, score=0.6623376623376623, total=   0.1s\n",
      "[CV] C=100, gamma=0.0001 .............................................\n",
      "[CV] ........ C=10, gamma=1.0, score=0.6818181818181818, total=   0.0s\n",
      "[CV] C=100, gamma=0.0001 .............................................\n",
      "[CV] ........ C=10, gamma=1.0, score=0.7581699346405228, total=   0.0s\n",
      "[CV] C=10, gamma=1.0 .................................................\n",
      "[CV] ........ C=10, gamma=1.0, score=0.6623376623376623, total=   0.1s\n",
      "[CV] C=10, gamma=1.0 .................................................\n",
      "[CV] .... C=100, gamma=0.0001, score=0.7727272727272727, total=   0.0s\n",
      "[CV] .... C=100, gamma=0.0001, score=0.7597402597402597, total=   0.0s\n",
      "[CV] C=100, gamma=0.0001 .............................................\n",
      "[CV] C=100, gamma=0.0001 .............................................\n",
      "[CV] ........ C=10, gamma=1.0, score=0.6753246753246753, total=   0.1s\n",
      "[CV] C=100, gamma=0.0001 .............................................\n",
      "[CV] ......... C=10, gamma=1.0, score=0.673202614379085, total=   0.1s\n",
      "[CV] .... C=100, gamma=0.0001, score=0.7467532467532467, total=   0.0s\n",
      "[CV] C=100, gamma=0.001 ..............................................\n",
      "[CV] C=100, gamma=0.001 ..............................................\n",
      "[CV] .... C=100, gamma=0.0001, score=0.7908496732026143, total=   0.0s\n",
      "[CV] C=100, gamma=0.01 ...............................................\n",
      "[CV] .... C=100, gamma=0.0001, score=0.7450980392156863, total=   0.0s\n",
      "[CV] C=100, gamma=0.001 ..............................................\n",
      "[CV] ..... C=100, gamma=0.001, score=0.7467532467532467, total=   0.0s\n",
      "[CV] C=100, gamma=0.001 ..............................................\n",
      "[CV] ..... C=100, gamma=0.001, score=0.7973856209150327, total=   0.0s\n",
      "[CV] ..... C=100, gamma=0.001, score=0.7792207792207793, total=   0.0s\n",
      "[CV] C=100, gamma=0.001 ..............................................\n",
      "[CV] C=100, gamma=0.01 ...............................................\n",
      "[CV] ..... C=100, gamma=0.001, score=0.7597402597402597, total=   0.0s\n",
      "[CV] C=100, gamma=0.01 ...............................................\n",
      "[CV] ...... C=100, gamma=0.01, score=0.7402597402597403, total=   0.1s\n",
      "[CV] C=100, gamma=0.01 ...............................................\n",
      "[CV] ..... C=100, gamma=0.001, score=0.7581699346405228, total=   0.0s\n",
      "[CV] C=100, gamma=0.1 ................................................\n",
      "[CV] ...... C=100, gamma=0.01, score=0.7597402597402597, total=   0.0s\n",
      "[CV] C=100, gamma=0.01 ...............................................\n",
      "[CV] ...... C=100, gamma=0.01, score=0.7777777777777778, total=   0.1s\n",
      "[CV] C=100, gamma=0.1 ................................................\n",
      "[CV] ...... C=100, gamma=0.01, score=0.7207792207792207, total=   0.1s\n",
      "[CV] C=100, gamma=0.1 ................................................\n",
      "[CV] ...... C=100, gamma=0.01, score=0.7973856209150327, total=   0.0s\n",
      "[CV] ....... C=100, gamma=0.1, score=0.6948051948051948, total=   0.1s\n",
      "[CV] C=100, gamma=1 ..................................................\n",
      "[CV] C=100, gamma=0.1 ................................................\n",
      "[CV] ......... C=100, gamma=1, score=0.6818181818181818, total=   0.0s\n",
      "[CV] C=100, gamma=1 ..................................................\n",
      "[CV] ....... C=100, gamma=0.1, score=0.6818181818181818, total=   0.1s\n",
      "[CV] C=100, gamma=1 ..................................................\n",
      "[CV] ....... C=100, gamma=0.1, score=0.7516339869281046, total=   0.1s\n",
      "[CV] C=100, gamma=0.1 ................................................\n",
      "[CV] ....... C=100, gamma=0.1, score=0.7012987012987013, total=   0.1s\n",
      "[CV] C=100, gamma=1 ..................................................\n",
      "[CV] ......... C=100, gamma=1, score=0.6558441558441559, total=   0.1s\n",
      "[CV] .......... C=100, gamma=1, score=0.673202614379085, total=   0.0s\n",
      "[CV] C=100, gamma=1.0 ................................................\n",
      "[CV] ......... C=100, gamma=1, score=0.6883116883116883, total=   0.1s\n",
      "[CV] C=100, gamma=1.0 ................................................\n",
      "[CV] ........ C=100, gamma=0.1, score=0.738562091503268, total=   0.1s\n",
      "[CV] C=100, gamma=1 ..................................................\n",
      "[CV] C=100, gamma=1.0 ................................................\n",
      "[CV] ....... C=100, gamma=1.0, score=0.6818181818181818, total=   0.0s\n",
      "[CV] C=1000, gamma=0.0001 ............................................\n",
      "[CV] ....... C=100, gamma=1.0, score=0.7516339869281046, total=   0.0s\n",
      "[CV] C=100, gamma=1.0 ................................................\n",
      "[CV] ....... C=100, gamma=1.0, score=0.6558441558441559, total=   0.1s\n",
      "[CV] ......... C=100, gamma=1, score=0.7516339869281046, total=   0.0s\n",
      "[CV] ... C=1000, gamma=0.0001, score=0.7597402597402597, total=   0.0s\n",
      "[CV] C=100, gamma=1.0 ................................................\n",
      "[CV] C=1000, gamma=0.0001 ............................................\n",
      "[CV] C=1000, gamma=0.0001 ............................................\n",
      "[CV] ........ C=100, gamma=1.0, score=0.673202614379085, total=   0.0s\n",
      "[CV] C=1000, gamma=0.0001 ............................................\n",
      "[CV] ... C=1000, gamma=0.0001, score=0.7467532467532467, total=   0.0s\n",
      "[CV] C=1000, gamma=0.001 .............................................\n",
      "[CV] ... C=1000, gamma=0.0001, score=0.7792207792207793, total=   0.0s\n",
      "[CV] ... C=1000, gamma=0.0001, score=0.7647058823529411, total=   0.0s\n",
      "[CV] C=1000, gamma=0.0001 ............................................\n",
      "[CV] C=1000, gamma=0.001 .............................................\n",
      "[CV] ....... C=100, gamma=1.0, score=0.6883116883116883, total=   0.1s\n",
      "[CV] C=1000, gamma=0.001 .............................................\n",
      "[CV] .... C=1000, gamma=0.001, score=0.7597402597402597, total=   0.0s\n",
      "[CV] C=1000, gamma=0.001 .............................................\n",
      "[CV] .... C=1000, gamma=0.001, score=0.7647058823529411, total=   0.0s\n",
      "[CV] C=1000, gamma=0.001 .............................................\n",
      "[CV] .... C=1000, gamma=0.001, score=0.7402597402597403, total=   0.0s\n",
      "[CV] ... C=1000, gamma=0.0001, score=0.7908496732026143, total=   0.0s\n",
      "[CV] C=1000, gamma=0.01 ..............................................\n",
      "[CV] C=1000, gamma=0.01 ..............................................\n",
      "[CV] .... C=1000, gamma=0.001, score=0.7450980392156863, total=   0.0s\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[CV] .... C=1000, gamma=0.001, score=0.7727272727272727, total=   0.0s\n",
      "[CV] C=1000, gamma=0.01 ..............................................\n",
      "[CV] C=1000, gamma=0.1 ...............................................\n",
      "[CV] ..... C=1000, gamma=0.01, score=0.7532467532467533, total=   0.1s\n",
      "[CV] C=1000, gamma=0.01 ..............................................\n",
      "[CV] ..... C=1000, gamma=0.01, score=0.7597402597402597, total=   0.1s\n",
      "[CV] C=1000, gamma=0.01 ..............................................\n",
      "[CV] ..... C=1000, gamma=0.01, score=0.7777777777777778, total=   0.1s\n",
      "[CV] C=1000, gamma=0.1 ...............................................\n",
      "[CV] ...... C=1000, gamma=0.1, score=0.7142857142857143, total=   0.2s\n",
      "[CV] ..... C=1000, gamma=0.01, score=0.7207792207792207, total=   0.1s\n",
      "[CV] C=1000, gamma=0.1 ...............................................\n",
      "[CV] C=1000, gamma=0.1 ...............................................\n",
      "[CV] ...... C=1000, gamma=0.1, score=0.6753246753246753, total=   0.2s\n",
      "[CV] ...... C=1000, gamma=0.01, score=0.803921568627451, total=   0.2s\n",
      "[CV] C=1000, gamma=1 .................................................\n",
      "[CV] C=1000, gamma=1 .................................................\n",
      "[CV] ........ C=1000, gamma=1, score=0.6818181818181818, total=   0.0s\n",
      "[CV] C=1000, gamma=1 .................................................\n",
      "[CV] ........ C=1000, gamma=1, score=0.6883116883116883, total=   0.1s\n",
      "[CV] ...... C=1000, gamma=0.1, score=0.6753246753246753, total=   0.2s\n",
      "[CV] C=1000, gamma=1 .................................................\n",
      "[CV] C=1000, gamma=1 .................................................\n",
      "[CV] ........ C=1000, gamma=1, score=0.6558441558441559, total=   0.1s\n",
      "[CV] C=1000, gamma=1.0 ...............................................\n",
      "[CV] ......... C=1000, gamma=1, score=0.673202614379085, total=   0.0s\n",
      "[CV] C=1000, gamma=1.0 ...............................................\n",
      "[CV] ........ C=1000, gamma=1, score=0.7516339869281046, total=   0.1s\n",
      "[CV] C=1000, gamma=1.0 ...............................................\n",
      "[CV] ...... C=1000, gamma=1.0, score=0.6818181818181818, total=   0.0s\n",
      "[CV] ...... C=1000, gamma=1.0, score=0.6558441558441559, total=   0.1s\n",
      "[CV] C=1000, gamma=1.0 ...............................................\n",
      "[CV] ...... C=1000, gamma=1.0, score=0.7516339869281046, total=   0.0s\n",
      "[CV] C=1000, gamma=1.0 ...............................................\n",
      "[CV] ....... C=1000, gamma=0.1, score=0.673202614379085, total=   0.4s\n",
      "[CV] C=1000, gamma=0.1 ...............................................\n",
      "[CV] ...... C=1000, gamma=1.0, score=0.6883116883116883, total=   0.0s\n",
      "[CV] ....... C=1000, gamma=1.0, score=0.673202614379085, total=   0.0s\n",
      "[CV] ...... C=1000, gamma=0.1, score=0.6666666666666666, total=   0.1s\n",
      "0.7682291666666666\n",
      "{'C': 100, 'gamma': 0.001}\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "[Parallel(n_jobs=-1)]: Done 210 out of 210 | elapsed:    5.1s finished\n"
     ]
    }
   ],
   "source": [
    "#RBF核函数超参数调优\n",
    "from sklearn.model_selection import StratifiedKFold\n",
    "fold=StratifiedKFold(n_splits=5,shuffle=True,random_state=777)\n",
    "from sklearn.model_selection import GridSearchCV\n",
    "from sklearn.svm import SVC\n",
    "#设置参数搜索范围\n",
    "gamma_s=[0.0001,0.001,0.01,0.1,1,1.0]\n",
    "Cs=[0.001,0.01,0.1,1,10,100,1000]\n",
    "\n",
    "#调优的参数集合，在网格上的交叉点进行搜索\n",
    "tuned_parameters=dict(gamma=gamma_s,C=Cs)\n",
    "SVC2=SVC(kernel='rbf')\n",
    "grid=GridSearchCV(SVC2,tuned_parameters,cv=5,scoring='accuracy',n_jobs=-1,verbose=5)\n",
    "grid.fit(X_train,y_train)\n",
    "print(grid.best_score_)\n",
    "print(grid.best_params_)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "线性SVC的最优结果为0.7721354166666666，参数{'C': 0.01, 'penalty': 'l2'}\n",
    "核函数的最优结果0.7682291666666666，{'C': 100, 'gamma': 0.001}\n",
    "核函数的非线性模型反而没有线性模型的正确率高，正确率相差不大。核函数的运行计算量较多，运行速度较慢，在此题中选择线性模型具有优势。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
